<?php
if(!defined('BZ_XTBLOG') || !defined('BZ_WJSCUZ')) {
	exit('Access Denied');
}
$fid =verify_id($_GET['fid']);
$top =verify_id($_GET['top']);
$act =$_GET['act'];
if($act == 'postsc'){
   $fid=$_COOKIE['fid'];
   $gid =$_GET['fid'];
}
$forum=$db->get_one('forum_class'," `id` ='$fid'",'');
$user_czqx=$user_class->user_qx('forum',$forum[id],$user_uid);
$wzxx_title =$forum['name'].'-发表帖子-'.$wzxx_title.'';
$wzxx_gj    =$forum['value'].'-发表帖子-'.$wzxx_gj.'';
$wzxx_ms    =$forum['value'].'-发表帖子-'.$wzxx_ms.'';
     $ltid  =$forum[id];
     $lttsj =$forum[tzszj];
     $ltts  =$forum[tzst];
     $ltname=$forum[name];
     $ltnamej=$forum[value];
     $ltflsz =$forum[sz_fl];
     $forum_config_datags=Bingz_config('forum_config_datags');
     if(!$forum_config_datags){
     	   Bingz_config('forum_config_datags','5','post');
     	   $forum_config_datags='5';
     }
if(!$forum){
		$pdid='1';
}else if(!$user_uid){
		$pdid='2';
}else if($forum[sz_fbqx] == '2' && $user_czqx < '5'){
		$pdid='11';
}else if($forum[sz_fbqx] == '3' && $user_czqx < '7'){
		$pdid='11';
}else if($forum[sz_fbqx] == '4' && $user_czqx < '10'){
		$pdid='11';
}else if($forum[sz_fbqx] == '5'){
		$pdid='10';
}else if($act == 'post'){
          if($db->num_rows('forum_data'," `uid` ='$user_uid' AND `fid` ='0'") > ($forum_config_datags - 1)){
             $tjts="会员临时空间附件只能存放 $forum_config_datags 个！<br/>";
          }else{
          	$mmurl=date("Y/m/d/");
            $bzwjc=Bingz_upload('forum/'.$mmurl,'0','2');
            if($bzwjc[1] == '1'){
          	 if(in_array($bzwjc[4], array('jpg','jpeg','png','gif'))) {$fjlx='1';}else{$fjlx='2';}
             if($db->insert('forum_data','`id`, `uid`, `money`, `url`, `name`, `fjgs`, `fjlx`, `size`, `time_a`',"NULL ,  '$user_uid', '$_POST[money]' , '$mmurl$bzwjc[2]', '$bzwjc[5]', '$fjlx', '$bzwjc[4]', '$bzwjc[3]', '$time'")){
                $id=$db->insert_id();
                $tjts="上传成功<br/>";
             }else{
		            $tjts="上传失败<br/>";
             }
    	      }else{
		           $tjts="上传失败<br/>上传附件：".$bzwjc[2]."<br/>";
            }
          } 
	        $pdid='3';
}else if($act == 'postsc'){
          $forum_data=$db->get_one('forum_data'," `id` ='$gid'",'');
          @unlink (Bingz_upload_images('data/forum/'.$forum_data[url].''));
          @unlink ('data/forum/'.$forum_data[url]);
          $db->delete('forum_data'," `id` ='$gid'",'');
	        $pdid='4';
}else if($act == 'postscqb'){
      $tzfl=$db->query('forum_data'," `uid` ='$user_uid' AND `fid` ='0' ORDER BY `id` ",'');
      while($forum_data=mysql_fetch_array($tzfl)){
          @unlink (Bingz_upload_images('data/forum/'.$forum_data[url].''));
          @unlink ('data/forum/'.$forum_data[url]);
          $db->delete('forum_data'," `id` ='$forum_data[id]'",'');
      }
	        $pdid='4';
}else if($act == 'tp'){
	    $tpsk=$_GET[tpsk];
	    if(!$tpsk){
		     $tpsk=3;
		     $h=0;
		     while($h < $tpsk){
			     $files=$files.'<input class="text" name="tp[]" type="text" /><a href="index.php?'.$bzml.'=forum&amp;'.$bzmd.'=post&amp;fid='.$ltid.'&amp;act=tp'.$bzsid.'&tpsk='.$h.'">删除</a><br />
			     ';
			     $h++;
		     }
	    }else{
		     $h=0;
		     while($h < $tpsk){
			     $files=$files.'<input class="text" name="tp[]" type="text" /><a href="index.php?'.$bzml.'=forum&amp;'.$bzmd.'=post&amp;fid='.$ltid.'&amp;act=tp'.$bzsid.'&tpsk='.$h.'">删除</a><br />
			     ';
			     $h++;
		     }
	    }
	    $h=$h+1;
		  $zjyx='<a href="index.php?'.$bzml.'=forum&amp;'.$bzmd.'=post&amp;fid='.$ltid.'&amp;act=tp'.$bzsid.'&tpsk='.$h.'">+增加一项</a><br />';
		  $tpsk=$tpsk;
		  $tpk =$files.$zjyx;
		  $pdid='33';
}else if($act == 'xs'){
		$hyjb=$user[money];
		$pdid='44';
}else if($act == 'pa'){
		$hyjb=$user[money];
		$pdid='55';
}
$tzfl=$db->query('forum_tzfl'," `fid` ='$forum[id]' ORDER BY `px` ",'');
while($fl=mysql_fetch_array($tzfl)){
  $ltfl[]= array("fid"=>"$fid","id"=>"$fl[id]","name"=>"$fl[name]");
}
$data_count=$db->num_rows('forum_data',"`uid` ='$user_uid' AND `fid` ='0' ORDER BY `id` ",'id');
$tzfl=$db->query('forum_data',"`uid` ='$user_uid' AND `fid` ='0' ORDER BY `id` ",'');
while($fl=mysql_fetch_array($tzfl)){
	$forum_sj     =Bingz_time($fl[time_a]);
  $data[]= array("id"=>"$fl[id]","money"=>"$fl[money]","size"=>"$fl[size]","sj"=>"$forum_sj","name"=>"$fl[name]","url"=> 'data/forum/'.$fl[url]);
}
setcookie('fid',$fid);
if($_GET['id']){
   $datasj='[attach]'.$_GET['id'].'[/attach]';
}
@include template('head');
@include template('forum/forum_post');
@include template('foot');
?>